<?php

namespace App\Http\Requests\App\V1\UserLogin;

use App\Http\Requests\ApiRequest;
use App\Services\EasySms\AliSMSCountry;
use Illuminate\Http\UploadedFile;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\In;

/**
 * Class UserUpdateRequest
 *
 * @property UploadedFile|string avatar
 * @property string|null nick_name
 * @property int|null sex
 *
 * @package App\Http\Requests\App\V1\User
 */
class UserLoginVerifyCodeRequest extends ApiRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $dial_codes = array_column(AliSMSCountry::codeMap(), 'dial_code');

        $rule = [
            'area_code' => ['required', 'string', Rule::in($dial_codes)],
            'phone'     => ['required', 'string', 'min:5', 'max:15'],
        ];

        return $rule;
    }
}
